Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nice_things/path/file_name.sh

file_name

Since 0.3.0 · Source

import "{ file_name }" from nice_things/path/file_name.sh

Synopsis
file_name <out_var> <pathname> [<suffix>]

Configuration

Description
Get <pathname> with any leading directory components removed. If specified, also remove a trailing <suffix>.

The result is similar to the basename utility specified in POSIX.

Options

Operands

  • <out_var>: Output variable; the result will be written to this variable.
  • <pathname>: A path name.
  • <suffix>: An optional suffix.

Stdin

Stdout

Stderr

Exit status
0: Successful completion.

Abort

Usage examples

# Get name of current program
file_name cmd "$0"

# Get file name with extension removed
file_name lib include/stdio.h .h # stdio